package com.ui.cases;

import com.ui.base.Base;
import org.openqa.selenium.By;
import org.testng.Assert;
import org.testng.annotations.Test;

public class RegisterCase extends Base {
    /*失败测试用例，手机号为空*/
    @Test
    public void failCase1(){
        driver.navigate().to("http://39.108.136.60:8085/lmcanon_web_auto/mng/register.html");
        driver.findElement(By.id("signup-button")).click();
        String errorMsg=driver.findElement(By.className("tips")).getText();
        Assert.assertEquals(errorMsg,"用户名不能为空");
    }
    //失败用例，使用非法手机号
    @Test
    public void failCase2(){
        driver.navigate().to("http://39.108.136.60:8085/lmcanon_web_auto/mng/register.html");
        driver.findElement(By.id("mobilephone")).sendKeys("aa");
        //点击注册按钮
        driver.findElement(By.id("signup-button")).click();
        String errorMsg=driver.findElement(By.className("tips")).getText();
        Assert.assertEquals(errorMsg,"非法的手机号");
    }
    //合法手机号，密码为空
    @Test
    public void failCase3(){
        driver.navigate().to("http://39.108.136.60:8085/lmcanon_web_auto/mng/register.html");
        driver.findElement(By.id("mobilephone")).sendKeys("18311447530");
        driver.findElement(By.id("signup-button")).click();
        String errorMsg=driver.findElement(By.className("tips")).getText();
        Assert.assertEquals(errorMsg,"密码不能为空");
    }
    //密码不满足要求
    @Test
    public void failCase4(){
        driver.navigate().to("http://39.108.136.60:8085/lmcanon_web_auto/mng/register.html");
        driver.findElement(By.id("mobilephone")).sendKeys("18311447530");
        driver.findElement(By.id("password")).sendKeys("12345");
        driver.findElement(By.id("signup-button")).click();

        String errorMsg=driver.findElement(By.className("tips")).getText();
        Assert.assertEquals(errorMsg,"密码长度至少为6位");
    }
    //重复密码为空
    @Test
    public void failCase5(){
        driver.navigate().to("http://39.108.136.60:8085/lmcanon_web_auto/mng/register.html");
        driver.findElement(By.id("mobilephone")).sendKeys("18311447530");
        driver.findElement(By.id("password")).sendKeys("1234578");
        driver.findElement(By.id("signup-button")).click();
        String errorMsg=driver.findElement(By.className("tips")).getText();
        Assert.assertEquals(errorMsg,"重复密码不能为空");
    }
    //重复与真实密码不一致
    @Test
    public void failCase6(){
        driver.navigate().to("http://39.108.136.60:8085/lmcanon_web_auto/mng/register.html");
        driver.findElement(By.id("mobilephone")).sendKeys("18311447530");
        driver.findElement(By.id("password")).sendKeys("12345789");
        driver.findElement(By.id("pwdconfirm")).sendKeys("1234567");
        driver.findElement(By.id("signup-button")).click();
        String errorMsg=driver.findElement(By.className("tips")).getText();
        Assert.assertEquals(errorMsg,"密码不一致");
    }

}
